<?php
/*
 * core/util.php
 *
 * Toolbox for various tasks
 *
 */

class Util
{
	/* 
	 * getUrlScriptName()
	 * return the full url to the currently executed page
	 */
	public static function getUrlScriptName()
	{
		$scr = (isset($_SERVER['HTTPS']))?'https':'http' . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
		return $scr;
	}

	/*
	 * getPregLastErrorString()
	 * return last PREG error as string
	 */
	public static function getPregLastErrorString()
	{
		switch( preg_last_error() )
		{
			case PREG_INTERNAL_ERROR: 				return 'Internal error'; break;
			case PREG_BACKTRACK_LIMIT_ERROR: 	return 'Backtrack limit error'; break;
			case PREG_RECURSION_LIMIT_ERROR: 	return 'Recursion limit error'; break;
			case PREG_BAD_UTF8_ERROR: 				return 'Bad UTF8 error'; break;
			case PREG_BAD_UTF8_OFFSET_ERROR:	return 'Bad UTF8 offset error'; break;
		}
		return 'Unknown error';
	}
};

?>
